﻿@extends('Layout/base')

@section('title', '登录，腕表商城！买手表，上腕表！')

{{--主内容样式--}}
@section('css')
    <link rel="stylesheet" href="{{asset('common/home/css/index.css')}}" type="text/css" media="screen, projection" />
    <style type="text/css">
    <!--
    .STYLE1 {font-size: large}
    .STYLE3 {
        font-size: medium;
        color: #CC0000;
    }
    -->
    </style>
@endsection

{{--主内容js--}}
@section('main-js')
   
    <script type="text/javascript" src="{{asset('common/home/js/jquery.js')}}"></script>
    <script type="text/javascript" src="{{asset('common/home/js/jquery-1.12.3.min.js')}}"></script>
    <!-- <script type="text/javascript" src="{{asset('common/home/js/index.js')}}"></script> -->
    <script src="{{asset('common/home/js/global.js')}}"></script>
@endsection

{{--主内容区--}}
@section('main')
<!--index banner start-->
<!--index banner end-->
<div style="width:1100px;height:500px; margin:0 auto;">
    <div style="width:600px;height:450px; float:left; margin-top:30px;border:1px solid;">
        <img src="{{asset('common/home/images/gg.jpg')}}" />
    </div>
    <div style="width:495px;height:450px; float:right;margin-top:30px;border:1px solid;">
        <div style="width:495px;height:20px; float:right;margin-top:20px;"align="right";>
            <span class="STYLE3">
                <a href="{{asset('/register')}}">注册新用户</a>
            </span>
        </div>
        <div style="width:495px;height:80px; float:right;margin-top:70px;"align="center";>
            <span class="STYLE1">用户名:</span>
            <input type="text" name="name" size="35" style="height:30px" placeholder="请输入用户名"/>
            <span  id='errorname' style="display:block; margin-top: 10px;color: red"></span>
        </div>
        <div style="width:495px;height:80px; float:right;" align="center";>
            <span class="STYLE1">密  码</span>：</span>
            <input type="password" name="pass" size="35" style="height:30px" placeholder="请输入密码"/>
            <span id="errorpass" style="display:block; margin-top: 10px;color: red"></span>
        </div>
         <div style="width:495px;height:80px; float:right;" align="center";>
            <span class="STYLE1">验证码:</span></span>
            <input type="text" name="mycode" size="19" style="height:30px" placeholder="请输入验证码" />
            <img src="{{url('/makecode')}}" id="imgcode" alt="" width="100" style="vertical-align:middle;" onclick="this.src='{{url("/makecode")}}?a='+Math.random();">
             <span id="errorcode" style="display:block; margin-top: 10px;color: red"></span>
        </div>

        <div style="width:495px;height:80px; float:right;" align="center";>
            <a href="javascript:;" class="login">
            <img src="{{asset('common/home/images/denglu.png')}}"></a>
            <a href="#"><strong> 忘记密码</strong></a>
        </div>
    </div>
</div>


<script type="text/javascript" >
  
      //点击登录
    $('a.login').on('click', function () {

        $('#errorname').html('');
        $('#errorpass').html('');
        $('#errorcode').html('');
        if (!$('input[name="name"]').val()) {
            $('#errorname').html('用户名不能为空！');
            return false;
        } 

        if (!$('input[name="pass"]').val()) {
            $('#errorpass').html('密码不能为空！');
            return false;
        }

        if (!$('input[name="mycode"]').val()) {
            $('#errorcode').html('验证码不能为空！');
            return false;
        }

        var uname = $('input[name="name"]').val();
        var upass = $('input[name="pass"]').val();
        var ucode = $('input[name="mycode"]').val();

        $('#errorname').html('');
        $('#errorpass').html('');
        $('#errorcode').html('');
        // alert(2);
        // console.log(uname);
         $.ajax({
            type: 'post',
            url: '{{url("/home/dologin")}}',
            data: 'name='+uname+'&pass='+upass+'&_token={{csrf_token()}}'+'&code='+ucode,
            success:function (data) {
                console.log(data);
                if (data.status == 100) {
                    $('#errorcode').html(data.msg).css('color','red');
                }
                 // 登录用户名错误
                if (data.status==2) {
                    $('#errorname').html(data.msg).css('color','red');
                    return false;
                }            
                //密码错误次数
                if (data.status==0) {
                    $('#errorpass').html(data.msg).css('color','red');
                    return false;
                }
                // 密码错误超过三次提示
                if (data.status==3) {
                    $('#errorcode').html(data.msg).css('color','red');
                    return false;
                }

                 // 登录成功
                if (data.status==1) {
                    $('#errorcode').html(data.msg).css('color','green');
                   location.href = '{{url("/")}}'; 
                }
                
            },
            error:function (err) {},
            dataType:'json'
        });
         
    });


</script>



<!--热销 start-->
<div id="hot_display_position"></div>
</div>
<p align="center">&nbsp;</p>

<!--热销 end-->

<div id="rank_display_position"></div>
</div>
<!--销售排行榜 end-->
</div>
<div id="floatBox">
    <div id="return">
        <a href="javascript:void(0);" class="c__gotop" title="返回顶部" style="display:none;" rel="nofollow"></a>
    </div>
</div>

@endsection



{{--尾部js--}}
@section('footer-js')
    <script type="text/javascript" src="{{asset('common/home/js/')}}"></script>
    <script type="text/javascript" src="{{asset('common/home/js/compare.js')}}"></script>
@endsection
